<html>
<head>
<meta charset="UTF-8">
<title>用户管理列表</title>
<link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js" type="text/javascript"></script>
<link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
<script type="text/javascript">

    $(function() {
        menuFuncOp($.getUrlParam('funcOpStr'));
    });

    //根据用户拥有的资源操作权限信息，动态控制按钮
    function menuFuncOp(funcOpStr) {
        if(null != funcOpStr && "" != funcOpStr){
            var linkButtons = document.getElementById("tb").getElementsByClassName("easyui-linkbutton");
            for(var i = 0; i < linkButtons.length; i++){
                if(funcOpStr.indexOf(linkButtons[i].id) == -1){
                    document.getElementById(linkButtons[i].id).style.display = 'none';
                }
            }
		}
    }

	function doAdd(){
		JLEUtil.createModalWin('新增', 'SUserAdd.html');
	}
	
	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
            if('0' == row.state){
                $.messager.alert('提示', '用户已注销，不能修改！','info');
                return;
            }
			JLEUtil.createModalWin('修改', 'SUserUpdate.html?' + 'actorno=' + row.actorno);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
            if('0' == row.state){
                $.messager.alert('提示', row.actorname + '，已注销，勿重复操作！','info');
                return;
            }
			$.messager.confirm('注销提示', '你确定要注销【' + row.actorname + '】这个用户?', function(r){
				if (r){
					var jsonData = JSON.parse('{'+'"actorno":"' + row.actorno + '"'+'}');
					$.restfulDelete('../../api/s/user', jsonData, function(data) {
						$.messager.alert('提示','记录注销成功!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','SUserView.html?' + '&actorno=' + row.actorno);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

    function setRoles(){
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            if('0' == row.state){
                $.messager.alert('提示', '用户已注销，不能设置！','info');
                return;
            }
            JLEUtil.createModalWin('角色设置','SUserSetRoles.html?' + '&actorno=' + row.actorno);
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

    function resetPassword(){
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('提示', '你确定要重置【' + row.actorname + '】这个用户的密码?', function(r){
                if (r){
                    var jsonData = JSON.parse('{'+'"actorno":"' + row.actorno + '"'+'}');
                    $.restfulPostJson('../../api/user/reset/pwd', jsonData, function(data) {
                        $.messager.alert('提示','密码重置成功!','info');
                        $('#dg').datagrid('reload');
                    });
                }
            });
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};	
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',title:''" style="height: 12%; width:100%; ">
	<form id="searchForm">
		<table>
			<tr>
				<td>&nbsp;用户码：</td>
				<td><input name="actorno" id="actorno"/></td>
				<td>&nbsp;用户名称：</td>
				<td><input name="actorname" id="actorname"/></td>
				<td>&nbsp;机构号：</td>
				<td><input name="orgid" id="orgid"/></td>
				<td>&nbsp;部门编号：</td>
				<td><input name="depno" id="depno"/></td>
			</tr>
			<tr>
				<td>&nbsp;状态：</td>
				<td><select name="state" id="state" class="easyui-combobox" style="width: 100%; height: 25px;"
							data-options="editable:false,valueField:'enname',textField:'cnname',data:USER_STATUS"/></td>

				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.queryForm('searchForm','dg','../../api/s/users');">查找</a>
				<a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
			</tr>
		</table>
	</form>
</div>
<div data-options="region:'center',split:false">
<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:90%"
			data-options="singleSelect:true,collapsible:true,url:'../../api/s/users',method:'post'"
			toolbar="#tb"
		title="Load Data" 
		rownumbers="true" pagination="true" pageSize="20">
		<thead>
			<tr>
				<th data-options="field:'actorno',resizable:true" >用户码</th>
				<th data-options="field:'actorname',resizable:true" >用户名称</th>
				<th data-options="field:'orgid',resizable:true" >机构号</th>
				<th data-options="field:'depno',resizable:true" >部门编号</th>
				<th data-options="field:'telnum',resizable:true" >联系电话</th>
				<!--<th data-options="field:'isadmin',resizable:true" formatter="formatter_STD_PUB_YN">是否管理员</th>-->
				<th data-options="field:'state',resizable:true" formatter="formatter_USER_STATUS">状态</th>
			</tr>
		</thead>
	</table>
</div>
<div id="tb" style="padding:1px">
	<div style="margin-bottom:2px">
		<a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="create">新增</a>
		<a href="javascript:doUpdate()" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="modify">修改</a>
		<a href="javascript:doDelete()" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="delete">注销</a>
		<a href="javascript:doView()" class="easyui-linkbutton" iconCls="icon-ok" plain="true" id="detail">查看</a>
		<a href="javascript:setRoles()" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="config">设置角色</a>
		<a href="javascript:resetPassword()" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="reset">重置密码</a>
	</div>
</div>
</body>
</html>
